Skip to content

feat(task): record each sandbox a run creates, by step and provider, as evidence that is never drift - #1007

Open
earakely-scale wants to merge 3 commits into
mainfrom
edgararakelyan/run-evidence
Open

earakely-scale wants to merge 3 commits into
mainfrom
edgararakelyan/run-evidence

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Each attempt's run records now say where it ran. The lock gains a third part, evidence, which lists every sandbox the attempt created. Each entry gives:

  • the step whose work created the sandbox;
  • its provider, container or VM mode, platform and ID;
  • whether it served the deploy that created it.

The comparator classes all of this as never drift.

This is the first half of the last run-records PR. The second half, the image digest each sandbox actually ran, comes next as its own PR.

Why

Before this PR, the records listed sandbox providers only from the deployments a run's context keeps. That missed:

  • the rubrics judge's own agent sandbox, which the judge step keeps to itself;
  • a multi env's child computers on another provider, because only the top-level sandbox_type was read;
  • which link of a fallback chain such as modal,local actually served a deploy.

How

  • providers/sandbox_providers/created.py: a run-scoped collector, set up by run_recorded, that works the way the entity-read recorder does.
    • Each sandbox is attributed to the step that created it. step_dispatched sets the step, so a judge's sandbox belongs to its verifier step.
    • It only notes inside a run's context. A sandbox made outside a run, or on a thread that doesn't carry the run's context (such as the computer composer's build VMs), isn't listed.
  • SandboxProvider.__init_subclass__: wraps every provider's create_sandbox, create_vm and create_container, the base class's own included, so each notes what it returns.
    • This covers built-in providers, plugins, config-registered providers, hand-made instances and chains in one place.
    • The checks that compare a method with SandboxProvider's own still work: an inherited method is still the base's, and an override is still its own.
  • A sandbox that didn't serve is listed with served: false. That happens when:
    • its create call raised, including a nested create_vm inside a VM backend's create_container;
    • the env provider's deploy on that chain link failed (_SandboxEnvironmentProvider._attempt);
    • an agent's deploy failed after its create returned (A2AAgent.deploy, which covers a judge's own deploy);
    • the chain refused it as unable to run the image;
    • the config type check refused it;
    • a computer's first-boot probe made it.
  • What's listed is what a create returned. A sandbox a provider allocates and tears down itself inside a create that then raises (a VM whose setup fails) never reached the run, and nothing of the run ran in it, so it isn't listed. Catching those would need a hook in each provider's internals, and keeping the rule at the provider API is what lets one wrapper cover every provider, plugins included.
  • Runtime records: types.sandbox_providers now includes every provider that created a sandbox.
  • Comparator: a type only one attempt used is now a difference even when neither attempt can name its package, as for a provider configuration registers. It used to compare as None against an absent key and go unreported; it now compares as unknown.
  • Comparator rows: the new row sandboxes created, compared step by step, is never. A sandbox provider only one attempt used is also never, because a fallback serving on another link changes where a run ran, not what ran. A package change of a provider both attempts used stays soft, and an override that asked for another provider stays soft in the override row.
  • Docs: the run-records docs said verify_sandbox and run_container_unit_tests_verifier make their own sandboxes. They don't; they only reattach. The docs now say what is recorded.

Decided

  • The evidence lives in the lock, one entry per sandbox, dropped sandboxes included.
  • One wrapper on every provider's create methods.
  • The sandboxes, and a provider only one attempt used, are never drift.

Tests

  • tst/unit/providers/sandbox_providers/created_test.py:
    • step attribution, with concurrent steps kept apart;
    • nothing outside a run;
    • a VM backend's container listed once, as a container;
    • a nested create that raised;
    • a chain refusing a sandbox, an env deploy failing on one link, a probe, and a mistyped config provider;
    • a thread with the run's context versus one without it.
  • tst/unit/task/run_lock_test.py: a run through Task.run records a deploy's sandbox and a judge's own, by step, with the provider in the runtime types. The round trip covers the new fields, and an older lock reads without them.
  • tst/unit/task/drift_test.py:
    • the row's case and field coverage;
    • a fallback that served on another link is never drift;
    • a provider's package change is soft;
    • sandbox IDs and creation order don't count;
    • an older record compares without the new fields.
  • tst/unit/cli/task_diff_test.py: task diff lists a fallback as never and exits 0.
  • tst/unit/a2a_agent/deploy_cleanup_test.py: an agent deploy that fails or is cancelled while waiting for its card lists its sandbox as not served. This test fails without the fix.
  • drift_test.py also checks that a type only one attempt used shows as a difference though neither can name its package.
  • tst/integration/task_step/test_verify_sandbox_local.py: a run on a local sandbox records the sandbox its deploy created.

Testing on VMs

Runs on fresh agent-environments-admin EC2 hosts, with the stores on SQLite, MongoDB 7 (a one-node replica set) and DynamoDB Local:

  • Unit tier on Linux, at 90e313e: 23,153 passed. 4 failed, the same 4 that fail on these hosts for every branch (test_mcp_cli_builder codegen ×2, the chromium install's execute bits, a local sandbox's context zip).
  • This PR's tests: 10 clean repeats at 90e313e and 5 more at b0c13cf. Python 3.11.18: 557 passed.
  • Real runs through agent-env task run, on each backend:
    • A local VM deploy plus a step that creates two sandboxes of its own: each is listed under its step, with exactly the IDs the run made. Two such runs diff to no differences.
    • A task deploying a container on the chain kitflaky,local, where kitflaky is a config-registered kit provider whose VMs can't pull. When it refuses before making anything, local's container alone is listed. When it fails after making its VM, that VM is listed as discarded beside local's container. task diff between the two exits 0 with two never lines: the step's sandboxes, and type's package sandbox_providers kitflaky: - -> unknown.
  • Concurrency: LocalRunner, 16 workers, 64 runs at once in one process, on SQLite and MongoDB. Each run lists exactly its own 3 sandboxes, 192 in all, with none listed twice.
  • Chaos (feat(task): compare two attempts' run records by the lock table, and agent-env task diff #974's scenarios, which write these records):
    • kill -9 mid-run: 10/10 diffs said what they couldn't compare, on SQLite and MongoDB.
    • Network faults through toxiproxy: 30/30 right verdicts on MongoDB and DynamoDB Local.
  • Real Claude Code runs, Haiku, through agent-env run, with a Claude Code rubric judge on its own local sandbox: each run lists the deploy's sandbox and the judge's own under their steps, the judge graded, and the two runs diff to no differences.
  • No hosts or handoff objects are left.

CI

The failing checks here are failing on main the same way: fastapi 0.165.1 can't call the installed opentelemetry-api.

Once #1005 merges I'll merge main and rerun.

🤖 Generated with Claude Code

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge; no new actionable issues were found.

Summary

Records each sandbox returned to a run, including its step, provider, mode, platform, ID, and whether it served.

  • Task runs now keep a step-by-step record of created sandboxes.
  • Task diffs show sandbox changes as evidence, not changes in what ran.

Reviews (8) · Last reviewed commit: "fix(task): a type only one attempt used ..." · Reviewed by Greptile

…as evidence that is never drift

Each attempt's lock gains an evidence part: every sandbox the run created, with the step whose work created it, its
provider, mode, platform and id, and whether it served the deploy that created it. Every provider's create_sandbox,
create_vm and create_container note what they return (SandboxProvider.__init_subclass__), in the run's context, so a
judge's own sandbox and a multi env's child computers are listed, and a sandbox made outside a run isn't. A sandbox
didn't serve when its create raised, the deploy on its chain link failed, the chain refused it, or a probe made it.

The runtime's sandbox provider types now include every provider that created a sandbox. In the comparator, the
sandboxes each step created are never drift, and so is a sandbox provider only one attempt used, as a fallback's next
link serving a deploy changes where it ran, not what ran; a package change of a provider both used stays soft.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner December 4, 2026 18:27
earakely-scale and others added 2 commits December 4, 2026 10:43
…he sandbox as one that served nothing

A2AAgent.deploy owns the sandbox once its create returns: loading the image, starting the agent or waiting for its card
can still fail, and the deploy then closes the sandbox, which the run now lists as discarded, a judge's own included.
A sandbox a provider allocates and tears down itself inside a create that raises isn't listed: no create handed it to
the run, and nothing of the run ran in it; the docs say so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r attempt can name its package

A run records a type's package as None when it can't name one, as for a class configuration registers, a sandbox
provider among them. The comparator read that as the type's absence, so a type only one attempt used went unreported;
it now compares as "unknown".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant